def find_lowest(costs,processed):
    infinity=float("inf")
    lowest_cost=infinity
    lowest_node=None
    for node in costs.keys():
        if costs[node]<lowest_cost and node not in processed:
            lowest_cost=costs[node]
            lowest_node=node
    return lowest_node

def search():
    graph={}
    graph['start']={}
    graph['start']['a']=6
    graph['start']['b']=2
    graph['a']={}
    graph['a']['fin']=1
    graph['b']={}
    graph['b']['fin']=5
    graph['b']['a']=3
    graph['fin']={}
    costs={}
    costs['a']=6
    costs['b']=2
    infinity=float("inf")
    costs['fin']=infinity
    parents={}
    parents['a']='start'
    parents['b']='start'
    parents['fin']=None
    processed=[]
    search_obj=find_lowest(costs,processed)
    while (search_obj):
        neigbors=graph[search_obj].keys()
        cost=costs[search_obj]
        for n in neigbors:
            new_cost=cost+graph[search_obj][n]
            if (new_cost<costs[n]):
                costs[n]=new_cost
                parents[n]=search_obj
        processed.append(search_obj)   
        search_obj=find_lowest(costs,processed)
    short_path=[]
    short_path.append('fin')
    while(short_path[-1]!='start'):
        short_path.append(parents[short_path[-1]])
    short_path.reverse()
    print(short_path)
def main():
    search()
if __name__=="__main__":
    main()